<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2019/11/1
  Time: 19:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>药品管理</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/vendors/iconfonts/mdi/css/materialdesignicons.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/vendors/css/vendor.bundle.base.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">
    <!-- endinject -->
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/images/favicon.png" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/page.css"/>
</head>
<body>
<div class="container-scroller">
    <nav class="navbar default-layout-navbar col-lg-12 col-12 p-0 fixed-top d-flex flex-row">
        <div class="text-center navbar-brand-wrapper d-flex align-items-center justify-content-center">
            <a class="navbar-brand brand-logo" href="index.html"><img src="${pageContext.request.contextPath}/images/logo.svg" alt="logo"/></a>
            <a class="navbar-brand brand-logo-mini" href="index.html"><img src="${pageContext.request.contextPath}/images/logo-mini.svg" alt="logo"/></a>
        </div>
        <div class="navbar-menu-wrapper d-flex align-items-stretch">
            <div class="search-field d-none d-md-block">
                <form class="d-flex align-items-center h-100" action="#">
                    <div class="input-group">
                        <div class="input-group-prepend bg-transparent">
                            <i class="input-group-text border-0 mdi mdi-magnify"></i>
                        </div>
                        <input type="text" class="form-control bg-transparent border-0" placeholder="search ">
                    </div>
                </form>
            </div>
            <ul class="navbar-nav navbar-nav-right">
                <li class="nav-item nav-profile dropdown">
                    <a class="nav-link dropdown-toggle" id="profileDropdown" href="#" data-toggle="dropdown" aria-expanded="false">
                        <div class="nav-profile-img">
                            <img src="${pageContext.request.contextPath}/images/faces/face1.jpg" alt="image">
                            <span class="availability-status online"></span>
                        </div>
                        <div class="nav-profile-text">
                            <p class="mb-1 text-black">David Greymaax</p>
                        </div>
                    </a>
                    <div class="dropdown-menu navbar-dropdown" aria-labelledby="profileDropdown">
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="#">
                            <i class="mdi mdi-logout mr-2 text-primary"></i>
                            Signout
                        </a>
                    </div>
                </li>

            </ul>
            <button class="navbar-toggler navbar-toggler-right d-lg-none align-self-center" type="button" data-toggle="offcanvas">
                <span class="mdi mdi-menu"></span>
            </button>
        </div>
    </nav>
    <!-- partial -->
    <div class="container-fluid page-body-wrapper">
        <nav class="sidebar sidebar-offcanvas" id="sidebar">
            <ul class="nav">
                <li class="nav-item nav-profile">
                    <a href="#" class="nav-link">
                        <div class="nav-profile-image">
                            <img src="${pageContext.request.contextPath}/images/faces/face1.jpg" alt="profile">
                            <span class="login-status online"></span> <!--change to offline or busy as needed-->
                        </div>
                        <div class="nav-profile-text d-flex flex-column">
                            <span class="font-weight-bold mb-2">David Grey. H</span>
                            <span class="text-secondary text-small">Project Manager</span>
                        </div>
                        <i class="mdi mdi-bookmark-check text-success nav-profile-badge"></i>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/getDashboard">
                        <span class="menu-title">Dashboard</span>
                        <i class="mdi mdi-home menu-icon"></i>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/getRegistrationList">
                        <span class="menu-title">挂号信息管理</span>
                        <i class="mdi mdi-contacts menu-icon"></i>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/getInHospitalList">
                        <span class="menu-title">住院办理</span>
                        <i class="mdi mdi-crosshairs-gps menu-icon"></i>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/InHospitalAccount">
                        <span class="menu-title">住院结算</span>
                        <i class="mdi mdi-ambulance menu-icon"></i>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/getSendDrugList">
                        <span class="menu-title">在院发药</span>
                        <i class="mdi mdi-food menu-icon"></i>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/getDrugList">
                        <span class="menu-title">药品管理</span>
                        <i class="mdi mdi-hospital menu-icon"></i>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/getCPRList">
                        <span class="menu-title">检查收费项目登记</span>
                        <i class="mdi mdi-highway menu-icon"></i>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/getChargeProjectList">
                        <span class="menu-title">收费项目管理</span>
                        <i class="mdi mdi-key-plus menu-icon"></i>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/getDoctorList">
                        <span class="menu-title">门诊医生管理</span>
                        <i class="mdi mdi-lock-plus menu-icon"></i>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/getUserList">
                        <span class="menu-title">用户管理</span>
                        <i class="mdi mdi-new-box menu-icon"></i>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/getRolePage">
                        <span class="menu-title">角色管理</span>
                        <i class="mdi mdi-human menu-icon"></i>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/12_resource_management.html">
                        <span class="menu-title">资源管理</span>
                        <i class="mdi mdi-library-books menu-icon"></i>
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/13_password_management.html">
                        <span class="menu-title">密码管理</span>
                        <i class="mdi mdi-compass-outline menu-icon"></i>
                    </a>
                </li>
                <div class="tlinks">Collect from <a href="http://www.cssmoban.com/" >企业网站模板</a></div>
            </ul>
        </nav>
        <!-- partial -->
        <div class="main-panel">
            <div class="content-wrapper">


                <div class="row">
                    <div class="col-12 grid-margin stretch-card">
                        <div class="card">
                            <div class="card-body">
                                <form class="form-inline" method="get" action="04_in_the_hospital_and_settlement.html">
                                    <div class="input-group">
                                        <div class="input-group-prepend">
                                            <div class="input-group-text">药品名称:</div>
                                        </div>
                                        <input type="text" class="form-control form-control-sm" style="width: 180px;" id="binglihao" placeholder="药品名称">
                                    </div>
                                    <div class="input-group" style="margin-left: 20px;">
                                        <div class="input-group-prepend">
                                            <div class="input-group-text">药品类型:</div>
                                        </div>
                                        <select class="form-control form-control-sm" style="width: 180px;height: 44px;margin-top: 1px;">
                                            <option>处方药</option>
                                            <option>非处方</option>
                                            <option>中药</option>
                                        </select>
                                        <!-- <input type="text" class="form-control form-control-sm" style="width: 180px;" id="xingming" placeholder="姓名"> -->
                                    </div>
                                    <button style="margin-left: 20px;" type="submit" class="btn btn-gradient-primary btn-md">查询</button>
                                    <button type="reset" class="btn btn-gradient-primary btn-md" style="margin-left: 10px;">重置</button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12 grid-margin stretch-card">
                        <div class="card">
                            <div class="card-body">

                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th style="font-weight: bold;">
                                            药品编号
                                        </th>
                                        <th style="font-weight: bold;">
                                            药品名称
                                        </th>
                                        <th style="font-weight: bold;">
                                            药品类型
                                        </th>
                                        <th style="font-weight: bold;">
                                            简单描述
                                        </th>
                                        <th style="font-weight: bold;">
                                            状态
                                        </th>
                                        <th style="font-weight: bold;">
                                            剩余量
                                        </th>
                                        <th style="text-align: center;font-weight: bold;">
                                            操作
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody id="tbody">
                                    <tr>
                                        <td>J1121</td>
                                        <td>感冒药</td>
                                        <td>处方</td>
                                        <td>用于普通感冒</td>
                                        <td>销售中</td>
                                        <td>1000袋</td>
                                        <td>
                                            <a href="${pageContext.request.contextPath}/jumpUpdateDrug?drId=${drug}">更改</a>&nbsp;&nbsp;&nbsp;&nbsp;
                                            <a href="${pageContext.request.contextPath}/addDrugDetail?drId=${drug}">添加库存</a>&nbsp;&nbsp;&nbsp;&nbsp;
                                            <a href="${pageContext.request.contextPath}/getDrugDetaDesc?drId=${drug}">详情信息>>></a>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>

                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-6"  style="margin-top: 10px;">
                        <a href="${pageContext.request.contextPath}/jumpAddDrug" class="btn btn-outline-dark btn-sm">添加新药</a>
                        <button type="button" class="btn btn-outline-dark btn-sm">导出Excel</button>
                    </div>
                    <div class="col-6">
                        <div class="row">
                            <div class="col-12">
                                <ul id="pageList">
                                    <li>
                                        <a id="pre" href="#">上一页</a>
                                    </li>
                                    <li>
                                        <a id="showPage" href="#">1/10</a>
                                    </li>
                                    <li>
                                        <a id="next" href="#">下一页</a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>



            </div>
            <!-- content-wrapper ends -->
            <!-- partial:partials/_footer.html -->
            <footer class="footer">
                <div class="d-sm-flex justify-content-center justify-content-sm-between">
                    <span class="text-muted text-center text-sm-left d-block d-sm-inline-block">Copyright © 2019 <a href="" target="_blank">xxx医院</a>. All rights reserved. </span>
                    <span class="float-none float-sm-right d-block mt-1 mt-sm-0 text-center">程序视界 & I and
              <i class="mdi mdi-heart text-danger"></i> - 更多案例 <a href="https://www.github.com/" target="_blank" title="全球最大的程序社区">Github</a> - Collect from <a href="http://www.github.com/" title="网页模板" target="_blank">社区</a></span>
                </div>
            </footer>
            <!-- partial -->
        </div>
        <!-- main-panel ends -->
    </div>
    <!-- page-body-wrapper ends -->
</div>
<!-- container-scroller -->

<!-- plugins:js -->
<script src="${pageContext.request.contextPath}/vendors/js/vendor.bundle.base.js"></script>
<script src="${pageContext.request.contextPath}/vendors/js/vendor.bundle.addons.js"></script>
<!-- endinject -->
<!-- Plugin js for this page-->
<!-- End plugin js for this page-->
<!-- inject:js -->
<script src="${pageContext.request.contextPath}/js/off-canvas.js"></script>
<script src="${pageContext.request.contextPath}/js/misc.js"></script>
<!-- endinject -->
<!-- Custom js for this page-->
<script src="${pageContext.request.contextPath}/js/dashboard.js"></script>
<!-- End custom js for this page-->
<script>
    var pageNo=1;
    var pageSize=2;
    var hasNext=true;
    page(pageNo,pageSize);
    function page(pageNo,pageSize){
        $.getJSON("/getDrugPage",{pageNo:pageNo,pageSize:pageSize},function(data){
            console.log(data.hasNext)
            //console.log(data);
            hasNext=data.hasNext;
            var result = data.obj;
            var str="";
            for (var i=0;i<result.length;i++){
                str+="<tr>\n" +
                    "                                        <td>"+result[i].drId+"</td>\n" +
                    "                                        <td>"+result[i].drName+"</td>\n" +
                    "                                        <td>"+result[i].drType+"</td>\n" +
                    "                                        <td>"+result[i].drSimDesc+"</td>\n" +
                    "                                        <td>"+(result[i].drNumber>0?'销售中':'已售罄')+"</td>\n" +
                    "                                        <td>"+result[i].drNumber+"</td>\n" +
                    "                                        <td>\n" +
                    "                                            <a href=\"${pageContext.request.contextPath}/jumpUpdateDrug?drId="+result[i].drId+"\">更改</a>&nbsp;&nbsp;&nbsp;&nbsp;\n" +
                    "                                            <a href=\"${pageContext.request.contextPath}/jumpAddDrugStore?drId="+result[i].drId+"\">添加库存</a>&nbsp;&nbsp;&nbsp;&nbsp;\n" +
                    "                                            <a href=\"${pageContext.request.contextPath}/getDrugDetail?drId="+result[i].drId+"\">详情信息>>></a>\n" +
                    "                                        </td>\n" +
                    "                                    </tr>";

            }
            $("#tbody").html(str);
            var pages = pageNo+"/"+data.pageCount;
            $("#showPage").html(pages);
        });
    }
    $("#pre").click(function (){
        if (pageNo<=1){
            alert("已经第一页了")
        }else{
            pageNo=pageNo-1;
            page(pageNo,pageSize);
        }
    });
    $("#next").click(function (){
        if (hasNext!=true){
            alert("已经是最后一页了")
        }else{
            pageNo=pageNo+1;
            page(pageNo,pageSize);
        }
    });













</script>
</body>
</html>

